package com.ethanzzh.ethanzzh_xdclass.utils;

public class SimpleResponse<T> {
    private boolean success;
    private String msg;
    private T data;
    private long totalPage;

    public SimpleResponse(boolean success, String msg) {
        this.success = success;
        this.msg = msg;
    }

    public SimpleResponse() {
    }

    public SimpleResponse(boolean success, String msg, T data) {
        this.success = success;
        this.msg = msg;
        this.data = data;
    }

    public SimpleResponse(boolean success) {
        this.success = success;
    }

    public static SimpleResponse success() {
        return new SimpleResponse(true, "成功");
    }

    public static SimpleResponse success(Object data) {
        return new SimpleResponse(true, "成功", data);
    }

    public static SimpleResponse success(Object data, long count) {
        return new SimpleResponse(true, "成功", data, count);
    }

    public static SimpleResponse fail(String msg) {
        return new SimpleResponse(false, msg);
    }

    public SimpleResponse(boolean success, String msg, T data, long totalPage) {
        this.success = success;
        this.msg = msg;
        this.data = data;
        this.totalPage = totalPage;
    }

    public String toString() {
        return "SimpleResponse(success=" + this.isSuccess() + ", msg=" + this.getMsg() + ", data=" + this.getData() + ", totalPage=" + this.getTotalPage() + ")";
    }

    public boolean isSuccess() {
        return this.success;
    }

    public String getMsg() {
        return this.msg;
    }

    public T getData() {
        return this.data;
    }

    public long getTotalPage() {
        return this.totalPage;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public void setData(T data) {
        this.data = data;
    }

    public void setTotalPage(long totalPage) {
        this.totalPage = totalPage;
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof SimpleResponse)) {
            return false;
        } else {
            SimpleResponse<?> other = (SimpleResponse)o;
            if (!other.canEqual(this)) {
                return false;
            } else if (this.isSuccess() != other.isSuccess()) {
                return false;
            } else {
                label41: {
                    Object this$msg = this.getMsg();
                    Object other$msg = other.getMsg();
                    if (this$msg == null) {
                        if (other$msg == null) {
                            break label41;
                        }
                    } else if (this$msg.equals(other$msg)) {
                        break label41;
                    }

                    return false;
                }

                Object this$data = this.getData();
                Object other$data = other.getData();
                if (this$data == null) {
                    if (other$data != null) {
                        return false;
                    }
                } else if (!this$data.equals(other$data)) {
                    return false;
                }

                if (this.getTotalPage() != other.getTotalPage()) {
                    return false;
                } else {
                    return true;
                }
            }
        }
    }

    protected boolean canEqual(Object other) {
        return other instanceof SimpleResponse;
    }


}
